<template>
  <div id="address">
    <van-row>
      <van-col span="24">
        <van-nav-bar title="添加地址" left-text="返回" left-arrow @click-left="onClickLeft" />
      </van-col>
      <van-col span="24">
        <van-address-edit :area-list="areaList" show-delete show-set-default show-search-result :search-result="searchResult" :area-columns-placeholder="['请选择', '请选择', '请选择']" show-area @save="onSave" @delete="onDelete" @change-detail="onChangeDetail" />
      </van-col>
    </van-row>
  </div>
</template>
<script>
import { areaList } from '@vant/area-data'
import { Toast } from 'vant'
export default {
  name,
  data() {
    return {
      areaList,
      searchResult: []
    }
  },
  mounted() {
    console.log(this.$route.query)
  },
  methods: {
    onClickLeft() {
      this.$router.back()
    },
    onSave(content) {
      console.log(content)
      let data = {
        name: content.name, //收货人姓名
        tel: content.tel, //电话
        province: content.province, //省
        city: content.city, //市
        county: content.county, //区
        addressDetail: content.addressDetail, //详细地址
        isDefault: content.isDefault, //是否默认
        id: '' //修改地址时传当前地址id，添加地址时不用传
      }
      this.$post('address/save', data).then(result => {
        console.log(result)
        Toast.success('保存成功')
        this.$router.push('/ress')
      })
    },
    // 保存
    onChangeDetail(val) {},
    // 删除
    onDelete() {
      Toast.success('删除成功')
    }
  }
}
</script>
<style lang="less" scoped></style>
